<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateArticle extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('article', function (Blueprint $table) {
            $table->id();

            $table->unsignedTinyInteger("type")->default(1)->comment("内容分类 1 - 文章  2 - 视频");
            $table->string("title", "120")->default("")->comment("标题");
            $table->string("subTitle", "240")->default("")->comment("副标题");
            $table->string("description", "800")->default("")->comment("描述");
            $table->string("coverImgUrl")->default("")->comment("封面图");
            $table->json("previewUrl")->default(null)->comment("预览图 视频单独一张 文章类型多张");
            $table->text("content")->default("")->nullable(true)->comment("文章内容 ｜ 视频地址");

            $table->unsignedInteger("supportNum")->default(0)->comment("点赞数");
            $table->unsignedInteger("collectNum")->default(0)->comment("收藏数");
            $table->unsignedInteger("forwardNum")->default(0)->comment("转发数");
            $table->unsignedInteger("readNum")->default(0)->comment("阅读数");
            $table->unsignedInteger("showNum")->default(0)->comment("展示数");

            $table->unsignedInteger("effectiveTime")->default(0)->comment("生效时间");
            $table->unsignedTinyInteger("publishType")->default(0)->comment("0 - 发布草稿 1 - 定时发布 1 - 立即发布");
            $table->unsignedTinyInteger("status")->default(1)->comment("内容状态 0 - 已下架 1 - 已上架");

            $table->unsignedInteger("sort")->default(0)->comment("内容排序");
            $table->unsignedTinyInteger("putTop")->default(0)->comment("是否置顶 0 - 常规 1 - 置顶");
            $table->unsignedTinyInteger("isDeleted")->default(0)->comment("是否删除");
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '内容表【文章/视频】';

            $table->index(["type", "effectiveTime"], "idx_type_effectiveTime");
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('article');
    }
}
